package cn.gdrj.est.config;

import cn.gdrj.est.annotations.TokenUserHandlerMethodArgumentResolver;
import cn.gdrj.est.service.TokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;

/**
 * TODO(这里用一句话描述这个类的作用)
 *
 * @author jun
 * @date 2021/11/15
 */
@Configuration
public class EstWebMvcConfig implements WebMvcConfigurer {
    @Autowired
    private TokenService tokenService;

    @Override
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
            resolvers.add(tokenUserHandlerMethodArgumentResolver());
    }


    @Bean
    public TokenUserHandlerMethodArgumentResolver tokenUserHandlerMethodArgumentResolver(){
        TokenUserHandlerMethodArgumentResolver resolver = new TokenUserHandlerMethodArgumentResolver();
        resolver.setTokenService(tokenService);
        return resolver;
    }
}
